{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "da5c138b",
   "metadata": {},
   "source": [
    "---\n",
    "* 2023-10-09\n",
    "* 课程：Python语言\n",
    "* week05\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09e9002d",
   "metadata": {},
   "source": [
    "# 1. 用户输入\n",
    "\n",
    "> 1. input()\n",
    "> 2. input输出的数据类型是：string"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0f454a6d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:zhichao\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'zhichao'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input(\"name:\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "45eb979d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入用户名：zhichao\n",
      "请输入密码：123456\n"
     ]
    }
   ],
   "source": [
    "# 用户注册\n",
    "username = input(\"请输入用户名：\")\n",
    "password = input(\"请输入密码：\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e11f9d8e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "zhichao\n"
     ]
    }
   ],
   "source": [
    "print(username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "16672c7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123456\n"
     ]
    }
   ],
   "source": [
    "print(password)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8bacf1a",
   "metadata": {},
   "source": [
    "* 妙记： 两个 = 是等于的意思"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "dc4d57dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "欢迎尊贵的VVVIP用户登录！！！\n"
     ]
    }
   ],
   "source": [
    "# 用户登录\n",
    "\n",
    "if username == \"zhichao\" and password == \"123456\":\n",
    "    print(\"欢迎尊贵的VVVIP用户登录！！！\")\n",
    "else:\n",
    "    print(\"账号或密码不正确，请重新尝试！！！\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8e75a438",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入用户名：zhichao\n",
      "请输入密码：123456\n",
      "欢迎尊贵的VVVIP用户登录！！！\n"
     ]
    }
   ],
   "source": [
    "# 用户注册\n",
    "username = input(\"请输入用户名：\")\n",
    "password = input(\"请输入密码：\")\n",
    "# 用户登录\n",
    "if username == \"zhichao\" and password == \"123456\":\n",
    "    print(\"欢迎尊贵的VVVIP用户登录！！！\")\n",
    "else:\n",
    "    print(\"账号或密码不正确，请重新尝试！！！\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76e9e3d7",
   "metadata": {},
   "source": [
    "# 2. 用户规范化/格式化输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7d3ef622",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入你的姓名:zhichao\n",
      "输入你的年龄:18\n",
      "输入你的职业:IT\n",
      "输入你的薪资:30000\n",
      "-------INFO zhichao-----\n",
      "姓名是：zhichao\n",
      "年龄为：18 \n",
      "工作是：IT\n",
      "薪资为：30000\n"
     ]
    }
   ],
   "source": [
    "# 输入的内容\n",
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info为展示的数据\n",
    "info = \"\"\"-------INFO %s-----\n",
    "姓名是：%s\n",
    "年龄为：%s \n",
    "工作是：%s\n",
    "薪资为：%s\"\"\"%(name,name,age,job,salary)\n",
    "\n",
    "# 打印结果\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ee1a998",
   "metadata": {},
   "source": [
    "* 占位符：\n",
    "> 1. 顺序\n",
    "> 2. %s 代表 字符串 %d 代表数字(整数) %f 代表小数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "df0053f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入你的姓名:zhichao\n",
      "输入你的年龄:18\n",
      "输入你的职业:IT\n",
      "输入你的薪资:20000\n",
      "-------INFO zhichao-----\n",
      "姓名是：zhichao\n",
      "年龄为：18 \n",
      "工作是：IT\n",
      "薪资为：20000\n"
     ]
    }
   ],
   "source": [
    "# 输入的内容(后端)\n",
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info为展示的数据（前端）\n",
    "info = \"\"\"-------INFO {N}-----\n",
    "姓名是：{N}\n",
    "年龄为：{A} \n",
    "工作是：{J}\n",
    "薪资为：{S}\"\"\".format(N=name,J=job,S=salary,A=age)\n",
    "\n",
    "# 打印结果\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba6e4e12",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
